package com.mysafe.provision.model.account;

import java.io.Serializable;

import com.mysafe.provision.model.person.Person;

import javax.inject.Inject;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(schema = "sfe", name = "en_account")
@SequenceGenerator(schema = "sfe", name = "seq_en_account", allocationSize = 1)
public class Account implements Serializable {

	private static final long serialVersionUID = 938985749593149659L;

	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_en_account")
	@Column(name = "id_account")
	private Integer id;
	private String login;

	@OneToOne(cascade = CascadeType.ALL)
	@JoinColumn(name = "id_person")
	private Person person;

	@Transient
	private boolean logged;
	
	public Account() {
	}
	
	@Inject
	public Account(Person person) {
		this.person = person;
	}
	
	public Account(Integer id) {
		this.id = id;
	}
	
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getLogin() {
		return this.login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public Person getPerson() {
		return this.person;
	}

	public void setPerson(Person person) {
		this.person = person;
	}

	public boolean isLogged() {
		return logged;
	}

	public void setLogged(boolean logged) {
		this.logged = logged;
	}
}